package com.dlut.java3;


import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class T0914_XieCheng {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();

        fun1(n);
        fun2(n);



    }
    static void fun2(long n){
        long temp = 20;
        for (long i = 5; i <= n * 4 - 4; i++) {
            temp += i * 3;
            temp %= 10_0000_0007 ;
        }
        for (long i = n * 4 - 3; i <= n * n; i++) {
            temp += i * 4;
            temp %= 10_0000_0007 ;
        }
        System.out.println(temp);
    }

    static void fun1(long n){
        if (n == 2){
            System.out.println(20);
            return;
        }
        long temp1 = (5 + 4 * n - 4) * (2 * n - 4)  * 3 + 20;
        temp1 = temp1 % 10_0000_0007;
        long nn =  n *n;

        long t1 = nn + 4 * n - 3;
        t1 = t1 %10_0000_0007;
        long t2 = nn - 4 * n +4;
        t2 = t2 %10_0000_0007;

        long t = (t1 * t2 * 2) %10_0000_0007 ;

        long ans = (t + temp1)%10_0000_0007 ;

        System.out.println(ans);
    }

    /*
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int t = Integer.parseInt(s);
        for (int iii = 0; iii < t; iii++) {
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            String s3 = in.nextLine();
            int n = Integer.parseInt(s1);
            String[] ss2 = s2.split(" ");
            int[] nums = new int[n];
            for (int j = 0; j < n; j++) {
                nums[j] = Integer.parseInt(ss2[j]);
            }

            int rMax = 0, bMax = 0;
            int rMin = Integer.MAX_VALUE, bMin = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                if (s3.charAt(i) == 'R'){
                    rMax = Math.max(rMax, nums[i]);
                    rMin = Math.min(rMin, nums[i]);
                }
                if (s3.charAt(i) == 'B'){
                    bMax = Math.max(bMax, nums[i]);
                    bMin = Math.min(bMin, nums[i]);
                }
            }
            int max = rMax - bMin;
            max = Math.max(max, rMax - rMin);
            max = Math.max(max, bMax - bMin);
            System.out.println(max);
        }
    }
    */

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int[] arr1 = new int[4];
        int[] arr2 = new int[4];
        int sum1 = 0;
        int sum2 = 0;

        for (int i = 0; i < t; i++) {
            sum1 = 0;
            sum2 = 0;
            arr1[0] = in.nextInt();
            arr1[1] = in.nextInt();
            arr1[3] = in.nextInt();
            arr1[2] = in.nextInt();
            arr2[0] = in.nextInt();
            arr2[1] = in.nextInt();
            arr2[3] = in.nextInt();
            arr2[2] = in.nextInt();
            for (int j = 0; j < 4; j++) {
                sum1 += arr1[j];
                sum2 += arr2[j];
            }
            if (sum1 != sum2){
                System.out.println(-1);
            }else{
                if (sum1 == 0 || sum1 == 4){
                    System.out.println(0);
                }else if (sum1 == 1){
                    int a=0,b=0;
                    for (int j = 0; j < 4; j++) {
                        if (arr1[j] == 1){
                            a = j;
                        }
                        if (arr2[j] == 1){
                            b = j;
                        }
                    }
                    if (a == b)
                        System.out.println(0);
                    else if (Math.abs((a - b + 4) % 4) == 2){
                        System.out.println(2);
                    }else {
                        System.out.println(1);
                    }
                }else if (sum1 == 3){
                    int a=0,b=0;
                    for (int j = 0; j < 4; j++) {
                        if (arr1[j] == 0){
                            a = j;
                        }
                        if (arr2[j] == 0){
                            b = j;
                        }
                    }
                    if (a == b)
                        System.out.println(0);
                    else if (Math.abs((a - b + 4) % 4) == 2){
                        System.out.println(2);
                    }else {
                        System.out.println(1);
                    }
                }else {
                    int[] a = new int[2];
                    int[] b = new int[2];
                    int t1 =0, t2 =0;
                    for (int j = 0; j < 4; j++) {
                        if (arr1[j] == 1){
                            a[t1++] = j;
                        }
                        if (arr2[j] == 1){
                            b[t2++] = j;
                        }
                    }
                    int sum = Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]);
                    if (sum > 2)
                        System.out.println(sum-2);
                    else
                        System.out.println(sum);
                }
            }
        }
    }

    /*
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int a = k / 2;
        int b = k - a;
        double ans = (double) n * n / (a + 1) / (b + 1);
        System.out.printf("%.2f",ans);
    }*/

}